package com.pe.cineplanet.proyectocine.repository.hibernate;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.pe.cineplanet.proyectocine.domain.ComboDetalle;
import com.pe.cineplanet.proyectocine.repository.ComboDetalleRepository;

public class ComboDetalleRepositoryHibernate extends HibernateDaoSupport 
implements ComboDetalleRepository {
	
	//constructor
	@Autowired
	public ComboDetalleRepositoryHibernate(SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
	}

	public List<ComboDetalle> obtenerComboDetalles() {
		// TODO Auto-generated method stub
		return getHibernateTemplate().find("from ComboDetalle");
	}

	public ComboDetalle obtenerComboDetalle(int id_Combo) {
		// TODO Auto-generated method stub
		return (ComboDetalle) getSession().createQuery("from ComboDetalle u where u.id_Combo=?").setInteger(0, id_Combo).uniqueResult();
	}

	public void grabarComboDetalle(ComboDetalle obj) {
		// TODO Auto-generated method stub
		getHibernateTemplate().saveOrUpdate(obj);
	}

	public void removerComboDetalle(int id_Combo) {
		// TODO Auto-generated method stub
		ComboDetalle obj = obtenerComboDetalle(id_Combo);
		getHibernateTemplate().delete(obj);
	}

}
